home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr25 / me310.zip / UE310C.ZIP / TIPC.C < prev    next >
C/C++ Source or Header  |  1988-10-02  |  6KB  |  229 lines

  1. /*
  2.  * The routines in this file provide support for the TI-PC and other
  3.  * compatible terminals. It goes directly to the graphics RAM to do
  4.  * screen output. It compiles into nothing if not a TI-PC driver
  5.  */
  6.  
  7. #define termdef 1                       /* don't define "term" external */
  8.  
  9. #include        <stdio.h>
  10. #include        "estruct.h"
  11. #include    "etype.h"
  12. #include        "edef.h"
  13. #include    "elang.h"
  14.  
  15. #if     TIPC
  16.  
  17. #define NROW    25                      /* Screen size.                 */
  18. #define NCOL    80                      /* Edit if you want to.         */
  19. #define MARGIN  8                       /* size of minimim margin and   */
  20. #define SCRSIZ  64                      /* scroll size for extended lines */
  21. #define NPAUSE  200                     /* # times thru update to pause */
  22. #define BEL     0x07                    /* BEL character.               */
  23. #define ESC     0x1B                    /* ESC character.               */
  24. #define SPACE   32                      /* space character              */
  25. #define SCADD   0xDE000L                /* address of screen RAM        */
  26.  
  27. #define CHAR_ENABLE     0x08            /* TI attribute to show char    */
  28. #define TI_REVERSE      0x10            /* TI attribute to reverse char */
  29. #define BLACK   0+CHAR_ENABLE           /* TI attribute for Black       */
  30. #define BLUE    1+CHAR_ENABLE           /* TI attribute for Blue        */
  31. #define RED     2+CHAR_ENABLE           /* TI attribute for Red         */
  32. #define MAGENTA 3+CHAR_ENABLE           /* TI attribute for Magenta     */
  33. #define GREEN   4+CHAR_ENABLE           /* TI attribute for Green       */
  34. #define CYAN    5+CHAR_ENABLE           /* TI attribute for Cyan        */
  35. #define YELLOW  6+CHAR_ENABLE           /* TI attribute for Yellow      */
  36. #define WHITE   7+CHAR_ENABLE           /* TI attribute for White       */
  37.  
  38.  
  39. extern PASCAL NEAR ttopen();               /* Forward references.          */
  40. extern PASCAL NEAR ttgetc();
  41. extern PASCAL NEAR ttputc();
  42. extern PASCAL NEAR ttflush();
  43. extern PASCAL NEAR ttclose();
  44. extern PASCAL NEAR timove();
  45. extern PASCAL NEAR tieeol();
  46. extern PASCAL NEAR tieeop();
  47. extern PASCAL NEAR tibeep();
  48. extern PASCAL NEAR tiopen();
  49. extern PASCAL NEAR tikopen();
  50. extern PASCAL NEAR tirev();
  51. extern PASCAL NEAR ticres();
  52. extern PASCAL NEAR ticlose();
  53. extern PASCAL NEAR tikclose();
  54. extern PASCAL NEAR tiputc();
  55.  
  56. #if     COLOR
  57. extern PASCAL NEAR tifcol();
  58. extern PASCAL NEAR tibcol();
  59.  
  60. int     cfcolor = -1;           /* current forground color */
  61. int     cbcolor = -1;           /* current background color */
  62. int     ctrans[] =              /* ansi to ti color translation table */
  63.         {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
  64. #endif
  65.  
  66. /*
  67.  * Standard terminal interface dispatch table. Most of the fields point into
  68.  * "termio" code.
  69.  */
  70. TERM    term    = {
  71.     NROW-1,
  72.         NROW-1,
  73.         NCOL,
  74.         NCOL,
  75.         MARGIN,
  76.         SCRSIZ,
  77.         NPAUSE,
  78.         tiopen,
  79.         ticlose,
  80.         tikopen,
  81.         tikclose,
  82.         ttgetc,
  83.         tiputc,
  84.         ttflush,
  85.         timove,
  86.         tieeol,
  87.         tieeop,
  88.         tibeep,
  89.         tirev,
  90.         ticres
  91. #if     COLOR
  92.         , tifcol,
  93.         tibcol
  94. #endif
  95. };
  96.  
  97. extern union REGS rg;
  98.  
  99. #if     COLOR
  100. PASCAL NEAR setatt(attr)
  101. int attr;
  102. {
  103.         rg.h.ah = 0x16;         /* set the forground character attribute */
  104.         rg.h.bl = attr;
  105.         int86(0x49, &rg, &rg);
  106. }
  107.  
  108. PASCAL NEAR tifcol(color)           /* set the current output color */
  109.  
  110. int color;      /* color to set */
  111.  
  112. {
  113.         cfcolor = ctrans[color];
  114.         setatt (cfcolor);
  115. }
  116.  
  117. PASCAL NEAR tibcol(color)           /* set the current background color */
  118.  
  119. int color;      /* color to set */
  120.  
  121. {
  122.         cbcolor = ctrans[color];
  123. }
  124. #endif
  125.  
  126. PASCAL NEAR timove(row, col)
  127. {
  128.         rg.h.ah = 2;            /* set cursor position function code */
  129.         rg.h.dh = col;
  130.         rg.h.dl = row;
  131.         int86(0x49, &rg, &rg);
  132. }
  133.  
  134. PASCAL NEAR tieeol()        /* erase to the end of the line */
  135.  
  136. {
  137.         int ccol;       /* current column cursor lives */
  138.         int crow;       /*         row  */
  139.  
  140.         /* find the current cursor position */
  141.         rg.h.ah = 3;            /* read cursor position function code */
  142.         int86(0x49, &rg, &rg);
  143.         ccol = rg.h.dh;         /* record current column */
  144.         crow = rg.h.dl;         /* and row */
  145.  
  146.         rg.h.ah = 0x09;         /* Write character at cursor position */
  147.         rg.h.al = ' ';          /* Space */
  148.         rg.h.bl = cfcolor;
  149.         rg.x.cx = NCOL-ccol;    /* Number of characters to write */
  150.         int86(0x49, &rg, &rg);
  151.  
  152. }
  153.  
  154. PASCAL NEAR tiputc(ch)      /* put a character at the current position in the
  155.                        current colors */
  156.  
  157. int ch;
  158.  
  159. {
  160.         rg.h.ah = 0x0E;         /* write char to screen with current attrs */
  161.         rg.h.al = ch;
  162.         int86(0x49, &rg, &rg);
  163. }
  164.  
  165. PASCAL NEAR tieeop()                        /* Actually a clear screen */
  166. {
  167.  
  168.         rg.h.ah = 0x13;         /* Clear Text Screen and Home Cursor */
  169.         int86(0x49, &rg, &rg);
  170. }
  171.  
  172. PASCAL NEAR tirev(state)            /* change reverse video state */
  173.  
  174. int state;      /* TRUE = reverse, FALSE = normal */
  175.  
  176. {
  177.         setatt(state ? cbcolor : cfcolor);
  178. }
  179.  
  180. PASCAL NEAR ticres()    /* change screen resolution */
  181.  
  182. {
  183.     return(TRUE);
  184. }
  185.  
  186. PASCAL NEAR spal()        /* change palette string */
  187.  
  188. {
  189.     /*    Does nothing here    */
  190. }
  191.  
  192. PASCAL NEAR tibeep()
  193. {
  194.         bdos(6, BEL, 0);
  195. }
  196.  
  197. PASCAL NEAR tiopen()
  198. {
  199.     strcpy(sres, "NORMAL");
  200.         revexist = TRUE;
  201.         ttopen();
  202. }
  203.  
  204. PASCAL NEAR tikopen()
  205.  
  206. {
  207. }
  208.  
  209. PASCAL NEAR ticlose()
  210.  
  211. {
  212. #if     COLOR
  213.         tifcol(7);
  214.         tibcol(0);
  215. #endif
  216.         ttclose();
  217. }
  218.  
  219. PASCAL NEAR tikclose()
  220.  
  221. {
  222. }
  223. #else
  224. tihello()
  225. {
  226. }
  227. #endif
  228.  
  229.